/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Controller;

import Model.Grid;
import Views.CircleView;
import Views.RectangleView;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JRadioButton;

/**
 *
 * @author Sim
 */
public class ButtonController extends Controller implements ActionListener 
{    
    public ButtonController(Grid model, CircleView circleView, RectangleView rectangleView)
    {
        super(model,circleView,rectangleView);
    } 
   
    @Override
    public void actionPerformed(ActionEvent ae)
    {
        
         this.circleView.requestFocus();
         this.rectangleView.requestFocus();

        if (((JRadioButton) ae.getSource()).getActionCommand().equals("Circle") &&
                ((JRadioButton) ae.getSource()).isSelected()) {
            this.rectangleView.setVisible(false);
            this.circleView.setVisible(true);

        } 
        if (((JRadioButton) ae.getSource()).getActionCommand().equals("Rectangle") &&
                ((JRadioButton) ae.getSource()).isSelected()) {
            this.circleView.setVisible(false);
            this.rectangleView.setVisible(true);
        }
        if (((JRadioButton) ae.getSource()).getActionCommand().equals("All") &&
                ((JRadioButton) ae.getSource()).isSelected()) {
            this.circleView.setVisible(true);
            this.rectangleView.setVisible(true);
        }

    }
    
    
}
